﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.ProcessManagement.ProcessRouteItemVMs
{
    public partial class ProcessRouteItemRoutieDetailListVM : BasePagedListVM<ProcessRouteItem, ProcessRouteItemDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ProcessRouteItem", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("ProcessRouteItem", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<ProcessRouteItem>> InitGridHeader()
        {
            return new List<GridColumn<ProcessRouteItem>>{
                
                this.MakeGridHeader(x => x.GroupCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.工序组"].Value),
                this.MakeGridHeader(x => x.OpCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.工序编号"].Value),
                this.MakeGridHeader(x => x.OpName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.工序名称"].Value),
                this.MakeGridHeader(x => x.OpType).SetEditType(EditTypeEnum.ComboBox,typeof(OpTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.工序类型"].Value),
                this.MakeGridHeader(x => x.ErpOpCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.工厂工序"].Value),
                this.MakeGridHeader(x => x.StdOpDuration).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.标准加工工时"].Value),
                this.MakeGridHeader(x => x.StdPrepDuration).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.标准准备工时"].Value),
                this.MakeGridHeader(x => x.PolicyCheckPrevProc).SetEditType(EditTypeEnum.ComboBox,typeof(PolicyCheckPrevProcEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.校验上一工序动作"].Value),
                this.MakeGridHeader(x => x.PolicyCheckProcBom).SetEditType(EditTypeEnum.ComboBox,typeof(PolicyCheckProcBomEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.校验生产BOM动作"].Value),
                this.MakeGridHeader(x => x.PolicyCheckProcess).SetEditType(EditTypeEnum.ComboBox,typeof(PolicyCheckProcessEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.工艺校验策略"].Value),
                this.MakeGridHeader(x => x.CtlAttr).SetEditType(EditTypeEnum.ComboBox,typeof(ProcCtlAttrEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.工艺管控属性"].Value),
                this.MakeGridHeader(x => x.Pos).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.工艺位置"].Value),
                this.MakeGridHeader(x => x.Etag).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.处理标记"].Value),
                this.MakeGridHeader(x => x.Active).SetEditType(EditTypeEnum.ComboBox,Utils.GetBoolCombo(BoolComboTypes.YesNo, selectText:Wtm.Localizer?["Sys.PleaseSelect"])).SetTitle(@Localizer["Page.激活"].Value),
                this.MakeGridHeader(x => x.EquipmentId).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.关联设备"].Value),
                this.MakeGridHeader(x => x.EquipmentCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.设备编号"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<ProcessRouteItem> GetSearchQuery()
        {
                
            var id = (long?)Searcher.RoutieId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<ProcessRouteItem>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<ProcessRouteItem>()
                .Where(x => id == x.RoutieId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class ProcessRouteItemDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._ProcessRouteItem._Routie")]
        public string RoutieId { get; set; }
    }

}

